package com.yxh.bigdata.mapreduce.test.flowsum;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class FlowMapper extends Mapper<LongWritable, Text, Text, FlowWritable> {

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {

        String[] split = value.toString().split(" ");
        String phone = split[0];
        long upFlow = Long.valueOf(split[1]);
        long downFlow = Long.valueOf(split[2]);
        context.write(new Text(phone), new FlowWritable(upFlow, downFlow));
    }
}
